/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.NoteManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ListAppActivity extends AbstractAction
/*    */ {
/* 29 */   private static Logger logger = Logger.getLogger(ListAppActivity.class
/* 30 */     .getName());
/*    */ 
/*    */   public ListAppActivity(AbstractHttpServlet servlet)
/*    */   {
/* 33 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 40 */     User user = super.getLoginUser(request);
/* 41 */     String userId = Util.getURLParameter(request.getParameter("userId"));
/* 42 */     if ((userId == null) || (userId.trim().length() == 0)) {
/* 43 */       userId = user.userId;
/*    */     }
/* 45 */     else if (!user.isAdmin)
/*    */     {
/* 47 */       if (user.isGroupAdmin)
/*    */       {
/* 51 */         int groupId = super.getUserGroupId(user.companyId, userId);
/* 52 */         if (groupId != user.groupId)
/*    */         {
/* 54 */           userId = user.userId;
/*    */         }
/*    */ 
/*    */       }
/* 58 */       else if (!user.userId.equals(userId)) {
/* 59 */         userId = user.userId;
/*    */       }
/*    */     }
/*    */ 
/* 63 */     int offset = Util.getURLIntParameter(request.getParameter("offset"));
/* 64 */     response.setContentType("text/html;charset=utf-8");
/* 65 */     PrintWriter out = response.getWriter();
/* 66 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 68 */     NoteManager manager = new NoteManager();
/*    */     try {
/* 70 */       List result = manager.getUserNotes(userId, 
/* 71 */         offset, 10);
/* 72 */       jsonObject.put("error", "0");
/* 73 */       jsonObject.put("notes", result);
/*    */     } catch (DBException e) {
/* 75 */       jsonObject.put("error", "1");
/* 76 */       jsonObject.put("msg", "最新动态加载失败");
/* 77 */       logger.warn("get activity list failed", e);
/*    */     } catch (SQLException e) {
/* 79 */       jsonObject.put("error", "1");
/* 80 */       jsonObject.put("msg", "最新动态加载失败");
/* 81 */       logger.warn("get activity list failed", e);
/*    */     }
/* 83 */     out.println(jsonObject);
/* 84 */     out.flush();
/* 85 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ListAppActivity
 * JD-Core Version:    0.6.1
 */